#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/3/11

# 不同进程间内存是不共享的，要想实现两个进程间的数据交换，可以用以下方法：
#
# Queues
#
# 使用方法跟threading里的queue差不多
from multiprocessing import Process, Queue


def f(q):
    q.put([42, None, 'hello'])


if __name__ == '__main__':
    q = Queue()
    p = Process(target=f, args=(q,))
    p2 = Process(target=f, args=(q,))
    p.start()
    p2.start()
    print(q.get())  # prints "[42, None, 'hello']"
    print(q.get())  # prints "[42, None, 'hello']"
    p.join()
